<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace plugins\alioss;

use cmf\lib\Plugin;

class AliossPlugin extends Plugin{
    public $info = [
        'name'        => 'Alioss',
        'title'       => '阿里OSS',
        'description' => '阿里OSS',
        'status'      => 1,
        'author'      => 'xinge',
        'version'     => '1.0'
    ];

    public $hasAdmin = 0;//插件是否有后台管理界面

    // 插件安装
    public function install()
    {
        $storageOption = cmf_get_option('storage');
        if (empty($storageOption)) {
            $storageOption = [];
        }

        $storageOption['storages']['alioss'] = ['name' => '阿里OSS', 'driver' => '\\plugins\\qiniu\\lib\\Qiniu'];

        cmf_set_option('storage', $storageOption);
        return true;//安装成功返回true，失败false
    }

    // 插件卸载
    public function uninstall()
    {
        $storageOption = cmf_get_option('storage');
        if (empty($storageOption)) {
            $storageOption = [];
        }

        unset($storageOption['storages']['alioss']);

        cmf_set_option('storage', $storageOption);
        return true;//卸载成功返回true，失败false
    }
    
     public function fetchUploadView(&$param)
    {
//        $config     = $this->getConfig();
//        $accessKey  = $config['accessKey'];
//        $secretKey  = $config['secretKey'];
//        $uploadHost = 'upload.qiniup.com';
//        $token = $config['bucket'];
//        $this->assign('upload_host', $uploadHost);
//        $this->assign('qiniu_up_token', $token);
//        return $this->fetch('upload');
    }

}